package com.atguigu.gulimall.product.controller;

import com.atguigu.common.utils.R;
import com.atguigu.gulimall.product.service.SkuInfoService;
import com.atguigu.gulimall.product.vo.SkuItemVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.ExecutionException;

@RestController
@RequestMapping("product/item")
@Slf4j
public class ItemController {

    @Resource
    private SkuInfoService skuInfoService;

    /**
     * 根据skuId查询商品详情信息***
     * @param skuId
     * @return
     */
    @GetMapping("/itemList/{skuId}")
    public R skuItem(@PathVariable("skuId") Long skuId) throws ExecutionException, InterruptedException {
        System.out.println("准备查询" + skuId + "详情");
        SkuItemVo skuItemVo=skuInfoService.item(skuId);
        return R.ok().put("data",skuItemVo);
    }
}
